package com.itheima.Mapper;

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpLoginLog;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {


    /**
     * 查询所有员工信息
     */
    @Select("select * from emp")
    List<Emp> findlist();



    //基于PageHeler实现分页
/*    List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);*/
    List<Emp> list(EmpQueryParam empQueryParam);




  /* @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id=d.id limit #{start},#{pageSize}")
    List<Emp> list(@Param("start") Integer start, @Param("pageSize") Integer pageSize);*/



    /**
     * 新增员工数据
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp(username,password, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values (#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);


    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void updateById(Emp emp);


    @MapKey("name")
    List<Map<String, Object>> countEmpJobData();

    @MapKey("name")
    List<Map> countEmpGenderData();



    @Select("select * from emp where username = #{username} and password=#{password}")
    Emp getUsernameAndPassword(Emp emp);




    /*
    */
/***
     * 查询总数量
     * @return
     *//*

    @Select("select count(*) from emp")
    Long count();
*/

}
